#include<bits/stdc++.h>
using namespace std;
struct car{
    int d,v,a;
}c[100005];
int ch[100005];
int ov[1000005];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--)
    {
        long long n,m,l,v;
        cin>>n>>m>>l>>v;
        memset(c,0,sizeof(c));
        memset(ch,0,sizeof(ch));
        memset(ov,0,sizeof(ov));
        for(int i=0;i<n;i++)
        {
            cin>>c[i].d>>c[i].v>>c[i].a;
        }
        for(int i=0;i<m;i++)
        {
            cin>>ch[i];
        }
        long long s=0;
        for(int i=0;i<n;i++)
        {
            if(c[i].v<=v&&c[i].a<=0)
            {
                continue;
            }
            if(c[i].a>=0)
            {
                double te=v-c[i].v;



                if(c[i].d>ch[m-1])
                {
                    continue;
                }



                if(te<0)
                {
                    ov[c[i].d]++;
                    if(c[i].d<=ch[m-1])
                    {
                        s++;
                    }
                }
                else
                {
                    if(c[i].a==0)
                    {
                        continue;
                    }
                    ///*
                    double ti=te/c[i].a;
                    long double w=c[i].v*ti+c[i].a*ti*0.5;
                    w+=c[i].d;
                    w=int(w+0.0);
                    if(w>l)
                    {
                        continue;
                    }
                    ov[int(w)]++;

                    if(int(w)<ch[m-1]&&w<l)
                    {
                        s++;
                    }
                    //*/
                    /*
                    long long te=ch[m-1]-c[i].d;
                    long long sp=c[i].v*c[i].v+c[i].a*te;
                    //cout<<sp<<" ";
                    if(sp>=v*v)
                    {
                        s++;
                    }
                    */
                }
            }
        }
        int f=0;
        int j=0;
        int an0=0,an1=0;

        for(int i=0;i<l;i++)
        {
            f+=ov[i];
            if(i==ch[j])
            {
                if(j==m-1)
                {
                    an0=f;
                    an1=m-1;
                }
                j++;
            }
        }

        if(s==0)
        {
            an1=m;
        }
        else
        {
            an1=m-1;
        }
        cout<<s<<" "<<an1<<endl;
    }
}
